<template>
	<view class="news-item" @click="toDetail(news.id)">
		<image :src="news.img_url"/>
		<view class="right">
			<view class="title">{{news.title}}</view>
			<view class="info">
				<text>发表时间：{{news.add_time | dateFormat}}</text>
				<text>浏览：{{news.click}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			news: {
				type: Object,
				default: () => {}
			}
		},
		filters: {
			dateFormat(date) {
				return date.substring(0, date.length - 5).replace("T", " ");
			}
		},
		methods: {
			toDetail(id) {
				this.$emit('itemClick', id);
			}
		}
	}
</script>

<style scoped lang="scss">
	.news-item {
		display: flex;
		padding: 10rpx 20rpx;
		border-bottom: 1rpx solid $main-color;
		image {
			width: 200rpx;
			height: 150rpx;
			min-width: 200rpx;
			max-width: 200rpx;
		}
		.right {
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			margin-left: 15rpx;
			.title {
				font-size: 30rpx;
			}
			.info {
				font-size: 24rpx;
				display: flex;
				justify-content: space-between;
			}
		}
	}
</style>
